package com.enation.app.javashop.core.client.fallback.member;

import com.enation.app.javashop.core.client.feignimpl.member.MemberCouponClientFeigntImpl;
import com.enation.app.javashop.core.handler.BaseFallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.enation.app.javashop.model.member.dos.MemberCoupon;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * 会员相关熔断fallback factory
 * @author kingapex
 * @version 1.0
 * @data 2022/5/28 14:26
 **/
@Component
public class MemberCouponClientFallbackFactory extends BaseFallbackFactory<MemberCouponClientFeigntImpl> {
    @Override
    protected MemberCouponClientFeigntImpl fallback() {
        return new MemberCouponClientFallback();
    }

    /**
     * 会员相关熔断
     *
     * @author zh
     * @version v7.0
     * @date 18/9/27 下午3:44
     * @since v7.0
     */
    @Component
    public static class MemberCouponClientFallback implements MemberCouponClientFeigntImpl {

        private final Logger logger = LoggerFactory.getLogger(getClass());

        @Override
        public List listByCheckout(Long[] sellerIds, Long memberId) {
            logger.error("获取优惠券错误");
            List<MemberCoupon> memberCoupons = new ArrayList<>();
            return memberCoupons;
        }

        @Override
        public MemberCoupon getModel(Long memberId, Long mcId) {
            logger.error("获取会员Id为" + memberId + "的会员优惠券异常");
            return new MemberCoupon();
        }

        @Override
        public void updateSellerName(Long sellerId, String sellerName) {
            logger.error("更新我的优惠券的店铺名称异常sellerid："+sellerId+"，sellername："+sellerName);
        }
    }
}
